<template>
    <!-- <h1 :class="type">hello world</h1>
    <button @click="btn">点击进行切换样式</button> -->
    <h1 :style="type">hello world</h1>
    <button @click="btn">点击进行切换样式</button>
</template>

<script setup lang="js" name="test2">
import { ref } from 'vue';
let type = ref('');
function btn() {
    if (type.value === '') {
        type.value = {
            color: 'yellowgreen',
            fontSize: 30 + "px"
        }
    } else {
        type.value = ''
    }
}
</script>

<style>
.temp {
    color: yellowgreen;
    font-size: 30px;
}
</style>